﻿#region 命名空间

using System;
using System.Collections.Generic;
using System.Linq;
using Sharp.Domain.PlatformBoundedContext.PermissionModule.Aggregates;
using Sharp.Domain.Repositories;
using Sharp.Infrastructure;
using Sharp.Domain.Repository.EF;

#endregion

namespace Sharp.Domain.PlatformBoundedContext.UserModule.Aggregates
{
    public partial class UserGroupRepository : Repository<UserGroup>, IUserGroupRepository
    {

        /// <summary>
        /// 获取用户组权限
        /// </summary>
        /// <param name="userGroupId"></param>
        /// <returns></returns>
        public IEnumerable<Permission> GetPermissionByGroupId(Guid? userGroupId)
        {
            var userGroup = Get(x => x.Id == userGroupId, x => x.Permissions);

            return userGroup.Permissions;
        }

        public Result Delete(Guid[] ids)
        {
            var newids = ids.ToList();
            newids.Remove(new Guid("00000000-4444-4444-4444-444444444444"));//系统自带的组不能参与删除

            Remove(newids);

            return new Result();
        }
    }
}